package com.ruoyi.quartz.race.init;

import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

import com.alibaba.fastjson.JSON;
import com.ruoyi.quartz.race.model.RaceEntity;
import com.ruoyi.quartz.race.tool.TouzhuUtil;
import com.ruoyi.quartz.util.JedisUtil;

/**
 * 获取所有赛事及当前赛季
 */
public class ServiceTouzhu {

	public static Executor executor = Executors.newFixedThreadPool(10);

	private static void getCals(RaceEntity ce) {
		executor.execute(() -> {
			new TouzhuUtil(ce).start();
		});
	}

	public static void main(String[] args) {
		List<RaceEntity> resultList = JSON.parseArray(JedisUtil.get("raceList"), RaceEntity.class);
		System.out.println(resultList.size());
		for (int i = 0; i < resultList.size(); i++) {
			RaceEntity temp = resultList.get(i);
			getCals(temp);
		}
	}

	public static void process(String typeid) {
		List<RaceEntity> resultList = JSON.parseArray(JedisUtil.get(typeid), RaceEntity.class);
		for (int i = 0; i < resultList.size(); i++) {
			RaceEntity temp = resultList.get(i);
			getCals(temp);
		}
	}
	
	public static void processList(List<RaceEntity> resultList) {
		for (int i = 0; i < resultList.size(); i++) {
			RaceEntity temp = resultList.get(i);
			getCals(temp);
		}
	}
}
